package codeTop;

import java.util.ArrayList;
import java.util.List;

public class q145 {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        dfs(list,root);
        return list;
    }

    private void dfs(List<Integer> list, TreeNode node) {
        if (node == null) {
            return;
        }
        dfs(list,node.left);
        dfs(list,node.right);
        list.add(node.val);
    }
}
